package com.example.controller;

import com.bw.itext.pdf.service.PdfService;
import com.example.domain.Product;
import com.example.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * @className: ProductController
 * @author: Joe
 * @create: 2023-02-07 09:34
 * @description:产品列表
 */
@RefreshScope
@CrossOrigin
@RestController
@RequestMapping("/pro")
public class ProductController {
    @Autowired
    ProductService productService;
    @Autowired
    PdfService pdfService;

    /**
     * 列表集合 加 根据类型id查询
     * @param tid
     * @return
     */
    @RequestMapping("/list")
    public List<Product> list(Integer tid){
        return productService.getList(tid);
    }

    /**
     * 根据id获取一条数据
     * @param id
     * @return
     */
    @RequestMapping("/getById")
    public Product getById(Integer id){
        return productService.getById(id);
    }

}
